from zope.component import adapts
from zope.interface import implements
from archetypes.schemaextender.interfaces import ISchemaExtender
from Products.Archetypes.public import RichWidget
from Products.Archetypes.public import AnnotationStorage
from Products.ATContentTypes.interface.image import IATImage

from ely.imagecaption.extender.fields import TextField


class Image(object):

    adapts(IATImage)
    implements(ISchemaExtender)

    fields = [
        TextField(
            'caption',
            required = False,
            searchable = True,
            storage = AnnotationStorage(migrate=True),
            validators = ('isTidyHtmlWithCleanup',),
            default_output_type = 'text/x-html-safe',
            widget = RichWidget(
                description = '',
                rows = 25,
                ),
            ),
        ]

    def __init__(self, context):
         self.context = context

    def getFields(self):
         return self.fields
